package top.wardyan.wbaseswt.control;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;

import top.wardyan.wbaseswt.conf.Const;

public class WLabel extends CLabel{

	public WLabel(Composite parent, int style) {
		super(parent, SWT.SHADOW_NONE);
		
		this.createContent();
	}
	public WLabel(Composite parent, int style, Font font, String text, int align) {
		this(parent, style);
		this.setText(text);
		this.setAlignment(align);
		this.setFont(font);
	}
	public WLabel(Composite parent, Font font, String text, int align) {
		this(parent, SWT.NONE, font, text, align);
	}
	public WLabel(Composite parent, int x, int y, int width, int height, Font font, String text, int align) {
		this(parent, SWT.NONE);
		this.setBounds(x, y, width, height);
		this.setText(text);
		this.setAlignment(align);
		this.setFont(font);
	}
	
	private void createContent() {
		this.setFont(Const.getDefaultFont());
		this.setBackground(Const.COLOR_WHITE);
		this.setForeground(Const.COLOR_BLACK);
		//this.setAlignment(alignment);
	}

	@Override
	protected void checkSubclass() {}
	
	
	/**
	 * 取得控件右下角的定点的x
	 * @return
	 */
	public int getVertexX() {
		return this.getLocation().x + this.getSize().x;
	}
	/**
	 * 取得控件右下角的定点的y
	 * @return
	 */
	public int getVertexY() {
		return this.getLocation().y + this.getSize().y;
	}
}
